import React, { Component } from "react";
import { Input, Button, Form } from "antd";
import styles from "./TopSearch.less";

const FormItem = Form.Item;

@Form.create()
class TopSearch extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: props.visible,
    };
  }

  handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        this.props.handleSearch(values);
      }
    });
  };

  handleReset = () => {
    this.props.form.resetFields();
  };

  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <div className={styles.root}>
        <Form layout="inline" onSubmit={this.handleSubmit}>
          <FormItem label="姓名" colon={true}>
            {getFieldDecorator("name")(<Input placeholder="请输入姓名" />)}
          </FormItem>
          {/* <FormItem label="警号" colon={true}>
            {getFieldDecorator("policeId")(<Input placeholder="请输入警号" />)}
          </FormItem> */}
          <FormItem>
            <Button type="primary" htmlType="submit">
              查询
            </Button>
          </FormItem>
          <FormItem>
            <Button onClick={this.handleReset}>重置</Button>
          </FormItem>
        </Form>
      </div>
    );
  }
}

export default TopSearch;
